<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ssm.dao.IUserDAO">

	<sql id="query_column">
		platform_user.platform_user_userid "platform_user$platform_user_userid"
	</sql>

	<sql id="count_column">
		COUNT(platform_user.platform_user_id)
	</sql>

	<sql id="query_table">
		platform_user
		LEFT JOIN platform_user_role
		ON platform_user.platform_user_id = platform_user_role.platform_user_id
	</sql>

	<sql id="query_where">
		<where>
			<if test="$AND and $AND.size > 0">
				<foreach collection="$AND" item="i" separator="AND">
					<choose>
						<when test="i.$NOVALUE">
							${i.column} ${i.operator}
						</when>
						<when test="i.$SINGLE">
							${i.column} ${i.operator} #{i.value}
						</when>
						<when test="i.$BETWEEN">
							${i.column} BETWEEN #{i.begin} AND #{i.end}
						</when>
						<when test="i.$LIST">
							${i.column} ${i.operator}
							<foreach collection="i.list" item="v" open="(" separator="," close=")">
								#{v}
							</foreach>
						</when>
					</choose>
				</foreach>
			</if>
			<if test="$OR and $OR.size > 0">
				<foreach collection="$OR" item="i" open="OR (" separator="OR" close=")">
					<choose>
						<when test="i.$NOVALUE">
							${i.column} ${i.operator}
						</when>
						<when test="i.$SINGLE">
							${i.column} ${i.operator} #{i.value}
						</when>
						<when test="i.$BETWEEN">
							${i.column} BETWEEN #{i.begin} AND #{i.end}
						</when>
						<when test="i.$LIST">
							${i.column} ${i.operator}
							<foreach collection="i.list" item="item" open="(" separator="," close=")">#{item}</foreach>
						</when>
					</choose>
				</foreach>
			</if>
		<!-- 
			Filters : ~{table}.~{field}
			<if test="~{table}$~{field}$eq != null">AND ~{table}.~{field} <![CDATA[=]]> #{~{table}$~{field}$eq}</if>
			<if test="~{table}$~{field}$ne != null">AND ~{table}.~{field} <![CDATA[<>]]> #{~{table}$~{field}$ne}</if>
			<if test="~{table}$~{field}$lt != null">AND ~{table}.~{field} <![CDATA[<]]> #{~{table}$~{field}$lt}</if>
			<if test="~{table}$~{field}$lt_eq != null">AND ~{table}.~{field} <![CDATA[<=]]> #{~{table}$~{field}$lt_eq}</if>
			<if test="~{table}$~{field}$gt != null">AND ~{table}.~{field} <![CDATA[>]]> #{~{table}$~{field}$gt}</if>
			<if test="~{table}$~{field}$gt_eq != null">AND ~{table}.~{field} <![CDATA[>=]]> #{~{table}$~{field}$gt_eq}</if>
			<if test="~{table}$~{field}$like != null">AND ~{table}.~{field} LIKE CONCAT('%', ${~{table}$~{field}$ct}, '%')</if>
			<if test="~{table}$~{field}$not_like != null">AND ~{table}.~{field} NOT LIKE CONCAT('%', ${~{table}$~{field}$nc}, '%')</if>
			<if test="~{table}$~{field}$begin_like != null">AND ~{table}.~{field} LIKE CONCAT(${~{table}$~{field}$nl}, '%')</if>
			<if test="~{table}$~{field}$not_begin_like != null">AND ~{table}.~{field} NOT LIKE CONCAT(${~{table}$~{field}$nl}, '%')</if>
			<if test="~{table}$~{field}$end_like != null">AND ~{table}.~{field} LIKE CONCAT('%', ${~{table}$~{field}$nl})</if>
			<if test="~{table}$~{field}$not_end_like != null">AND ~{table}.~{field} NOT LIKE CONCAT('%', ${~{table}$~{field}$nl})</if>
			<if test="~{table}$~{field}$null != null">AND ~{table}.~{field} IS NULL</if>
			<if test="~{table}$~{field}$not_null != null">AND ~{table}.~{field} IS NOT NULL</if>
			<if test="~{table}$~{field}$empty != null">AND ~{table}.~{field} = ''</if>
			<if test="~{table}$~{field}$not_empty != null">AND ~{table}.~{field} <![CDATA[<>]]> ''</if>
			<if test="~{table}$~{field}$begin != null and ~{table}$~{field}$end != null">AND ~{table}.~{field} BETWEEN #{~{table}$~{field}$bt_bw} AND #{~{table}$~{field}$bt_ew}</if>
			<if test="~{table}$~{field}$not_begin != null and ~{table}$~{field}$not_end != null">AND ~{table}.~{field} NOT BETWEEN #{~{table}$~{field}$bt_bw} AND #{~{table}$~{field}$bt_ew}</if>
			<if test="~{table}$~{field}$in != null">AND ~{table}.~{field}<foreach collection="~{table}$~{field}$in" item="item" open="IN (" separator="," close=")">#{item}</foreach></if>
			<if test="~{table}$~{field}$not_in != null">AND ~{table}.~{field}<foreach collection="~{table}$~{field}$in" item="item" open="NOT IN (" separator="," close=")">#{item}</foreach></if>
		
		
			<if test="platform_user$or != null">
				AND
				<trim prefix="(" prefixOverrides="OR" suffix=")">
					
				</trim>
			</if>
			
			<trim prefixOverrides="AND | OR">
				<if test="platform_user$platform_user_id != null">
					<choose>
						<when test="platform_user$platform_user_id_and != null">AND</when>
						<when test="platform_user$platform_user_id_or != null">OR</when>
						<otherwise>AND</otherwise>
					</choose>
					platform_user.platform_user_id = #{platform_user.platform_user_id}
				</if>
				
				<if test="platform_user$platform_user_id_list != null">
					<choose>
						<when test="platform_user$platform_user_id_list_and != null">AND</when>
						<when test="platform_user$platform_user_id_list_or != null">OR</when>
						<otherwise>AND</otherwise>
					</choose>
					platform_user.platform_user_id
					<foreach collection="platform_user$platform_user_id_list" item="item" open="IN (" separator="," close=")">
						#{item}
					</foreach>
				</if>
			</trim> -->
		</where>
	</sql>

	<sql id="query_where">
		<where>

		</where>
	</sql>

	<sql id="query_gourp_by">
		<where>

		</where>
	</sql>

	<sql id="query_order_by">
		<where>

		</where>
	</sql>

	<sql id="query_limit">
		<where>

		</where>
	</sql>

	<sql id="insert_field">
	</sql>

	<sql id="insert_value">
	</sql>

	<sql id="update_set">
		<set>

		</set>
	</sql>

	<sql id="update_where">
		<where>

		</where>
	</sql>

	<sql id="delete_where">
		<where>

		</where>
	</sql>



	<select id="query" parameterType="hashmap" resultType="hashmap">
		SELECT
		<include refid="query_column" />
		FROM
		<include refid="query_table" />
		<include refid="query_where" />
		<include refid="query_gourp_by" />
		<include refid="query_having" />
		<include refid="query_order_by" />
		<include refid="query_limit" />
	</select>

	<select id="count" parameterType="hashmap" resultType="int">
		SELECT
		<include refid="count_column" />
		FROM
		<include refid="query_table" />
		<include refid="query_where" />
		<include refid="query_gourp_by" />
		<include refid="query_having" />
	</select>

	<insert id="insert" parameterType="hashmap" useGeneratedKeys="true" keyProperty="">
		INSERT INTO ${table}
		<include refid="insert_field" />
		VALUES
		<include refid="insert_value" />
	</insert>

	<update id="update" parameterType="hashmap">
		UPDATE ${table}
		<include refid="update_set" />
		<include refid="update_where" />
	</update>

	<#include "delete.ftl" />

</mapper>